<?php
/**
 * @Author: gan
 * @Description:
 * @File:  PushBase
 * @Version: 1.0.0
 * @Date: 2021/12/27 9:19 上午
 */
declare(strict_types=1);

namespace RX\Component\Push;

use RX\Component\Push\Impl\GeTuiImpl;
use RX\Component\Push\Impl\JpushImpl;
use RX\Component\Push\Impl\PushInterface;
use RX\Enums\CommonEnum;
use RX\Exception\BizException;

class PushStaticFactory
{
    /**
     * @param string $type
     * @param array $config
     * @return PushInterface
     * @throws BizException
     */
    public static function factory(string $type, array $config = []): PushInterface
    {
        switch ($type) {
            case PushType::JPUSH:
                return new JpushImpl($config);
            case PushType::GETUI:
                return new GeTuiImpl($config);
            default:
                throw new BizException(CommonEnum::class, CommonEnum::INVALID_PARAMS);
        }
    }
}
